package utils;

public class Line {
	private Position a;
	private Position b;
	
	/***
	 * 
	 * @param a
	 * @param b
	 */
	public Line(Position a, Position b) {
		super();
		this.a = a;
		this.b = b;
	}
	

	/**
	 * @return the a
	 */
	public Position getA() {
		return a;
	}

	/**
	 * @param a the a to set
	 */
	public void setA(Position a) {
		this.a = a;
	}

	/**
	 * @return the b
	 */
	public Position getB() {
		return b;
	}

	/**
	 * @param b the b to set
	 */
	public void setB(Position b) {
		this.b = b;
	}
	
	public float distance(){
		float dist = 0;
		
		dist = (float)Math.sqrt(Math.pow(this.b.getX()-this.a.getX(), 2)+ Math.pow(this.b.getY()-this.a.getY(), 2));
		
		return dist;
	}
	
	/**
	 * 
	 * @return d
	 */
	public int direction(){
		int d=0;
		//Horizontal
		if(this.a.getY() == this.b.getY()){
			d = 1;
		}
		//Vertical
		if(this.a.getX() == this.b.getX()){
			d = 2;
		}
		//Diagonal Izquierda Arriba
		if(this.a.getX() > this.b.getX() && this.a.getY() > this.b.getY()){
			d = 3;
		}
		//Diagonal Derecha Arriba
		if(this.a.getX() < this.b.getX() && this.a.getY() > this.b.getY()){
			d = 4;
		}
		//Diagonal Izquierda Abajo
		if(this.a.getX() > this.b.getX() && this.a.getY() < this.b.getY()){
			d = 5;
		}		
		//Diagonal Derecha Abajo
		if(this.a.getX() < this.b.getX() && this.a.getY() < this.b.getY()){
			d = 6;
		}
		
		return d;
	}

}
